#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int T, n, a[N], ans = -1;
void dfs(int id, int sum, int red, int blue)
{
    if (id == n + 1)
    {
        ans = max(ans, sum);
        // cerr << red << " " << blue << " " << sum << "\n";
        return;
    }
    if (a[red] == a[id])
        dfs(id + 1, sum + a[id], id, blue);
    else
        dfs(id + 1, sum, id, blue);
    if (a[blue] == a[id])
        dfs(id + 1, sum + a[id], red, id);
    else
        dfs(id + 1, sum, red, id);
}
int main()
{
    ios::sync_with_stdio(false);
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    cin >> T;
    while (T--)
    {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        dfs(1, 0, 0, 0);
        cout << ans << "\n";
        for (int i = 1; i <= n; i++)
            a[i] = 0;
        ans = -1;
    }
    return 0;
}